<?php

/**
 * This is the model class for table "sys_bonus_transfer".
 *
 * The followings are the available columns in table 'sys_bonus_transfer':
 * @property string $bonus_transfer_id
 * @property string $bonus_transfer_network_id
 * @property string $bonus_transfer_network_par_id
 * @property string $bonus_transfer_total_bonus
 * @property double $bonus_transfer_cut_index_percent
 * @property string $bonus_transfer_cut_index
 * @property double $bonus_transfer_cut_tax_percent
 * @property string $bonus_transfer_cut_tax
 * @property double $bonus_transfer_cut_auto_percent
 * @property string $bonus_transfer_cut_auto
 * @property string $bonus_transfer_cut_adm
 * @property string $bonus_transfer_value
 * @property string $bonus_transfer_caption
 * @property string $bonus_transfer_category
 * @property string $bonus_transfer_type
 * @property string $bonus_transfer_bank_id
 * @property string $bonus_transfer_bank_account_name
 * @property string $bonus_transfer_bank_account_no
 * @property string $bonus_transfer_tax_account_no
 * @property string $bonus_transfer_mobilephone
 * @property string $bonus_transfer_datetime
 *
 * The followings are the available model relations:
 * @property SysNetwork $bonusTransferNetwork
 * @property RefBank $bonusTransferBank
 */
class sys_bonus_transfer extends CActiveRecord {

    /**
     * Returns the static model of the specified AR class.
     * @return sys_bonus_transfer the static model class
     */
    public static function model($className=__CLASS__) {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName() {
        return 'sys_bonus_transfer';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules() {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('bonus_transfer_cut_index_percent, bonus_transfer_cut_tax_percent, bonus_transfer_cut_auto_percent', 'numerical'),
            array('bonus_transfer_network_id, bonus_transfer_network_par_id, bonus_transfer_total_bonus, bonus_transfer_cut_index, bonus_transfer_cut_tax, bonus_transfer_cut_auto, bonus_transfer_cut_adm, bonus_transfer_value, bonus_transfer_bank_id', 'length', 'max' => 10),
            array('bonus_transfer_caption, bonus_transfer_bank_account_name, bonus_transfer_bank_account_no, bonus_transfer_tax_account_no, bonus_transfer_mobilephone', 'length', 'max' => 255),
            array('bonus_transfer_category, bonus_transfer_type', 'length', 'max' => 7),
            array('bonus_transfer_datetime', 'safe'),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('bonus_transfer_id, bonus_transfer_network_id, bonus_transfer_network_par_id, bonus_transfer_total_bonus, bonus_transfer_cut_index_percent, bonus_transfer_cut_index, bonus_transfer_cut_tax_percent, bonus_transfer_cut_tax, bonus_transfer_cut_auto_percent, bonus_transfer_cut_auto, bonus_transfer_cut_adm, bonus_transfer_value, bonus_transfer_caption, bonus_transfer_category, bonus_transfer_type, bonus_transfer_bank_id, bonus_transfer_bank_account_name, bonus_transfer_bank_account_no, bonus_transfer_tax_account_no, bonus_transfer_mobilephone, bonus_transfer_datetime', 'safe', 'on' => 'search'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations() {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
            'rel_bonus_transfer_to_network' => array(self::BELONGS_TO, 'sys_network', 'bonus_transfer_network_id'),
            'rel_bonus_transfer_to_bank' => array(self::BELONGS_TO, 'ref_bank', 'bonus_transfer_bank_id'),
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
            'bonus_transfer_id' => 'Bonus Transfer',
            'bonus_transfer_network_id' => 'Bonus Transfer Network',
            'bonus_transfer_network_par_id' => 'Bonus Transfer Network Parent',
            'bonus_transfer_total_bonus' => 'Total Bonus',
            'bonus_transfer_cut_index_percent' => 'Cut Index Percent',
            'bonus_transfer_cut_index' => 'Cut Index',
            'bonus_transfer_cut_tax_percent' => 'Cut Tax Percent',
            'bonus_transfer_cut_tax' => 'Cut Tax',
            'bonus_transfer_cut_auto_percent' => 'Cut Automaintenance Percent',
            'bonus_transfer_cut_auto' => 'Cut Automaintenance',
            'bonus_transfer_cut_adm' => 'Cut Administration',
            'bonus_transfer_value' => 'Bonus Transfer Value',
            'bonus_transfer_caption' => 'Caption',
            'bonus_transfer_category' => 'Bonus Transfer Category',
            'bonus_transfer_type' => 'Bonus Transfer Type',
            'bonus_transfer_bank_id' => 'Bonus Transfer Bank',
            'bonus_transfer_bank_account_name' => 'Bank Account Name',
            'bonus_transfer_bank_account_no' => 'Bank Account No',
            'bonus_transfer_tax_account_no' => 'Tax Account No',
            'bonus_transfer_mobilephone' => 'Mobilephone',
            'bonus_transfer_datetime' => 'Bonus Transfer Datetime',
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search() {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria = new CDbCriteria;

        $criteria->compare('bonus_transfer_id', $this->bonus_transfer_id, true);
        $criteria->compare('bonus_transfer_network_id', $this->bonus_transfer_network_id, true);
        $criteria->compare('bonus_transfer_network_par_id', $this->bonus_transfer_network_par_id, true);
        $criteria->compare('bonus_transfer_total_bonus', $this->bonus_transfer_total_bonus, true);
        $criteria->compare('bonus_transfer_cut_index_percent', $this->bonus_transfer_cut_index_percent);
        $criteria->compare('bonus_transfer_cut_index', $this->bonus_transfer_cut_index, true);
        $criteria->compare('bonus_transfer_cut_tax_percent', $this->bonus_transfer_cut_tax_percent);
        $criteria->compare('bonus_transfer_cut_tax', $this->bonus_transfer_cut_tax, true);
        $criteria->compare('bonus_transfer_cut_auto_percent', $this->bonus_transfer_cut_auto_percent);
        $criteria->compare('bonus_transfer_cut_auto', $this->bonus_transfer_cut_auto, true);
        $criteria->compare('bonus_transfer_cut_adm', $this->bonus_transfer_cut_adm, true);
        $criteria->compare('bonus_transfer_value', $this->bonus_transfer_value, true);
        $criteria->compare('bonus_transfer_caption', $this->bonus_transfer_caption, true);
        $criteria->compare('bonus_transfer_category', $this->bonus_transfer_category, true);
        $criteria->compare('bonus_transfer_type', $this->bonus_transfer_type, true);
        $criteria->compare('bonus_transfer_bank_id', $this->bonus_transfer_bank_id, true);
        $criteria->compare('bonus_transfer_bank_account_name', $this->bonus_transfer_bank_account_name, true);
        $criteria->compare('bonus_transfer_bank_account_no', $this->bonus_transfer_bank_account_no, true);
        $criteria->compare('bonus_transfer_tax_account_no', $this->bonus_transfer_tax_account_no, true);
        $criteria->compare('bonus_transfer_mobilephone', $this->bonus_transfer_mobilephone, true);
        $criteria->compare('bonus_transfer_datetime', $this->bonus_transfer_datetime, true);

        return new CActiveDataProvider($this, array(
            'criteria' => $criteria,
        ));
    }

}